<?php
namespace app\common\model;

use think\Db;
use think\Model;

class PermitModel extends Model
{
    //
    public
        $table = 'cms_blog_permit',
        $pk = 'id';

    public function del($id)
    {
        try {
            $data = $this->destroy($id);
            if ($data) {
                return ['status' => 1, 'message' => '删除成功'];
            } else {
                return ['status' => 0, 'message' => '删除失败'];
            }
        } catch (\Exception $e) {
            echo $e->getMessage();
        }

    }

    public function getPermitInfo($where)
    {
        $res = $this->where($where)->find();
        return $res;
    }

    public function getPermitInfoAll()
    {
        $list = [];
        $data = Db::query("SELECT * FROM $this->table ");
        foreach ($data as $arr) {
            @$list[$arr['parent']][] = $arr;
        }
        return $list;
    }
}